package apps.softtech.fastmarket.model;

import android.content.ContentValues;
import android.database.Cursor;

public class FeedBack {

	public static final String TABLE_NAME = "FeedBack";

	public static final String FEEDBACK_ID = "st_FeedBackId";
	private int feedBackId;

	public static final String CONTENT_FEEDBACK = "st_ContentFeedBack";
	private String contentFeedBack;

	public static final String RATE = "st_Rate";
	private float rate;

	public static final String CREATED_DATE = "st_CreatedDate";
	private String createdDate;

	public static final String USERID = "st_UserId";
	private int userId;

	public static final String PRODUCT_ID = "st_ProductId";
	private int productId;

	public FeedBack() {
		super();
	}

	public FeedBack(int feedBackId, String contentFeedBack, float rate,
			String createdDate, int userId, int productId) {
		super();
		this.feedBackId = feedBackId;
		this.contentFeedBack = contentFeedBack;
		this.rate = rate;
		this.createdDate = createdDate;
		this.userId = userId;
		this.productId = productId;
	}

	public FeedBack(String contentFeedBack, float rate, String createdDate,
			int userId, int productId) {
		super();
		this.contentFeedBack = contentFeedBack;
		this.rate = rate;
		this.createdDate = createdDate;
		this.userId = userId;
		this.productId = productId;
	}
	
	/**
	 * get value of FeedBack
	 * @return ContentValues
	 */
	public ContentValues getValueFeedBack(){
		ContentValues values = new ContentValues();
		values.put(CONTENT_FEEDBACK, this.contentFeedBack);
		values.put(RATE, this.getRate());
		values.put(CREATED_DATE, this.getCreatedDate());
		values.put(USERID, this.getUserId());
		values.put(PRODUCT_ID, this.getProductId());
		return values;
	}

	public int getFeedBackId() {
		return feedBackId;
	}

	public void setFeedBackId(int feedBackId) {
		this.feedBackId = feedBackId;
	}

	public String getContentFeedBack() {
		return contentFeedBack;
	}

	public void setContentFeedBack(String contentFeedBack) {
		this.contentFeedBack = contentFeedBack;
	}

	public double getRate() {
		return rate;
	}

	public void setRate(float rate) {
		this.rate = rate;
	}

	public String getCreatedDate() {
		return createdDate;
	}

	public void setCreatedDate(String createdDate) {
		this.createdDate = createdDate;
	}

	public int getUserId() {
		return userId;
	}

	public void setUserId(int userId) {
		this.userId = userId;
	}

	public int getProductId() {
		return productId;
	}

	public void setProductId(int productId) {
		this.productId = productId;
	}

	public void setValueFromCursor(Cursor c) {
		
		if(c.getColumnIndex(FEEDBACK_ID)>=0){
			setFeedBackId(c.getInt(c.getColumnIndex(FEEDBACK_ID)));
		}
		if(c.getColumnIndex(CREATED_DATE)>=0){
			setCreatedDate(c.getString(c.getColumnIndex(CREATED_DATE)));
		}
		if(c.getColumnIndex(PRODUCT_ID)>=0){
			setProductId(c.getInt(c.getColumnIndex(PRODUCT_ID)));
		}
		if(c.getColumnIndex(RATE)>=0){
			setRate(c.getFloat(c.getColumnIndex(RATE)));
		}
		if(c.getColumnIndex(USERID)>=0){
			setUserId(c.getInt(c.getColumnIndex(USERID)));
		}
	}

}
